package com.ticket.sass.provider.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;
import java.util.Map;

/**
 * @author ywb
 * @date 2022-09-26 14:55
 */
@Slf4j
@Configuration
public class AppConfig {
    public static String KEY_PREFIX;
    
    public static String PWD_SECRET;
    
    public static String CLIENT_SECRET;
    
    public static String TOKEN_SECRET;
    
    public final static Map<String, String> FILE_NAME_MAP = new HashMap<String, String>() {
        {
            put("cinema-logo", "cinema/logo/");
            put("wx-cover", "wxa/cover/");
            put("member-cover", "member/cover");
            put("ad-material", "ad/material/");
            put("ad-advertiser-logo", "ad/advertiser/logo/");
            put("client-version-file", "client/app/");
            put("movie", "movie/");
            put("device-photo", "device/photo/");
            put("device-attachment", "device/attachment/");
        }
    };
    public final static String VALID_TOKEN_CACHE_KEY = "ticket-admin-uid:%s";
    
    public final static String VALID_LOGIN_COUNT_IP_KEY = "ticket-admin-ip:%s";
    
    public final static Integer VALID_LOGIN_LIMIT = 20;
    
    @Value("${config.key.prefix}")
    public void setKeyPrefix(String param) {
        KEY_PREFIX = param;
    }
    
    @Value("${config.jwt.secret}")
    public void setTokenSecret(String param) {
        TOKEN_SECRET = param;
    }
    
    @Value("${config.pwd.secret}")
    public void setPwdSecret(String param) {
        PWD_SECRET = param;
    }
    
    @Value("${config.client.secret}")
    public void setClientSecret(String param) {
        CLIENT_SECRET = param;
    }
}
